<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die( 'Restricted access' );

class JElementzRok extends JElement
{
	/**
	 * Element name
	 *
	 * @access	protected
	 * @var		string
	 */
	var	$_name = 'zrok';

	function fetchElement($name, $value, &$node, $control_name)
	{
		$db =& JFactory::getDBO();

    $query = 'SELECT DISTINCT YEAR(publish_up) AS title'
			. ' FROM #__jzmluvy'
      . ' WHERE catid = 1' // faktury
      . ' ORDER BY title DESC'      
		;

		$db->setQuery( $query );
		$options = $db->loadObjectList();

		array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Vyber rok').' -', 'title', 'title'));
    		
    return JHTML::_('select.genericlist',  $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'title', 'title', $value, $control_name.$name );
  }
}
